<!DOCTYPE html>
<html lang="en" style="background: #f3f3f3;">
<head>
    <meta charset="UTF-8">
    <title>登陆</title>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__STATIC__/css/global.css">
    <script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
</head>
<body class="body">

<div class="login_page">
    <div class="logo-login">
    </div>
    <h1>欢迎使用</h1>
    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-input-inline input-custom-width">
                <input type="text" name="username" lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-inline input-custom-width">
                <input type="password" name="password" lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-inline input-custom-width">
                <input type="text" name="captcha" lay-verify="required" placeholder="验证码" autocomplete="off" class="layui-input">
                <div class="captcha"><img src="{:captcha_src()}" onclick="this.src='/captcha?id='+Math.random()" alt="captche" title='点击切换'></div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-inline input-custom-width">
                <button class="layui-btn input-custom-width" lay-submit="" lay-filter="login">立即登陆</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    layui.use('form',function(){
        var form = layui.form
            ,jq = layui.jquery;

        //监听提交
        form.on('submit(login)', function(data){
            loading = layer.load(2, {
                shade: [0.2,'#000'] //0.2透明度的白色背景
            });
            var param = data.field;
            jq.post('',param,function(data){
                if(data.code == 1){
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                        location.href = data.url;
                    });
                }else {
                    layer.close(loading);
                    jq('.captcha img').attr('src','/captcha?id='+Math.random());
                    layer.msg(data.msg, {icon: 0, time: 1000});
                }
            });
            return false;
        });
    });
</script>
</body>
</html>